package jmine.tec.aom.domain.impl;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

import jmine.tec.aom.AOMMessages;
import jmine.tec.aom.domain.AbstractPropertyValue;
import jmine.tec.aom.exception.FillException;
import jmine.tec.persist.annotation.DiscriminatorComment;
import bancosys.tec.component.Documentation;

/**
 * {@link AbstractPropertyValue} implementation for the {@link Integer} type.
 * 
 * @author jrenaut
 */
@Entity
@DiscriminatorValue("7")
@DiscriminatorComment("INTEGER")
public class IntegerPropertyValue extends AbstractPropertyValue<Integer> {

    /**
     * {@inheritDoc}
     */
    @Override
    @Column(name = "VL_INTEGER")
    @Documentation("VALOR DA CARACTERISTICA DO TIPO INTEGER")
    public Integer getValue() {
        return super.getValue();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void doSetValue(String stringValue) throws FillException {
        try {
            this.setValue(Integer.parseInt(stringValue));
        } catch (NumberFormatException e) {
            throw new FillException(AOMMessages.INVALID_INTEGER_FORMAT.create(this.getPropertyName(), stringValue), e);
        }
    }

}
